﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Bot.Application.Dto;
using Bot.Application.Services;
using Microsoft.AspNetCore.Mvc;

namespace Bot.WebAPI.Controllers
{
    [Route("api/v3/chatbot")]
    [ApiController]
    public class MessageAfterSeveralConsecutivePossibleAnswersInChannelsController : ControllerBase
    {

        private readonly IMessageAfterSeveralConsecutivePossibleAnswersInChannelAppService _app;
        public MessageAfterSeveralConsecutivePossibleAnswersInChannelsController(IMessageAfterSeveralConsecutivePossibleAnswersInChannelAppService app)
        {
            this._app = app;
        }

        [HttpGet]
        [Route("messageAfterSeveralConsecutivePossibleAnswersInChannels/{id:Guid}")]
        public ActionResult<MessageAfterSeveralConsecutivePossibleAnswersInChannelDto> Get([FromRoute] Guid id)
        {
            MessageAfterSeveralConsecutivePossibleAnswersInChannelDto messageAfterSeveralConsecutivePossibleAnswersInChannel = _app.Get(id);
            return Ok(messageAfterSeveralConsecutivePossibleAnswersInChannel);
        }

        [HttpGet]
        [Route("bots/{botId:Guid}/messageAfterSeveralConsecutivePossibleAnswersInChannels")]
        public ActionResult<IEnumerable<MessageAfterSeveralConsecutivePossibleAnswersInChannelDto>> GetList([FromRoute] Guid botId)
        {
            IEnumerable<MessageAfterSeveralConsecutivePossibleAnswersInChannelDto> list = _app.GetByBotId(botId);
            return Ok(list);
        }

        [HttpPut]
        [Route("messageAfterSeveralConsecutivePossibleAnswersInChannels/{id:Guid}")]
        public ActionResult<MessageAfterSeveralConsecutivePossibleAnswersInChannelDto> Put([FromRoute] Guid id, [FromBody] MessageAfterSeveralConsecutivePossibleAnswersInChannelUpdateDto dto)
        {
            MessageAfterSeveralConsecutivePossibleAnswersInChannelDto messageAfterSeveralConsecutivePossibleAnswersInChannel = _app.Update(id, dto);
            return Ok(messageAfterSeveralConsecutivePossibleAnswersInChannel);
        }

        [HttpPost]
        [Route("bots/{botId:Guid}/messageAfterSeveralConsecutivePossibleAnswersInChannels")]
        public ActionResult<MessageAfterSeveralConsecutivePossibleAnswersInChannelDto> Post([FromRoute] Guid botId, [FromBody] MessageAfterSeveralConsecutivePossibleAnswersInChannelCreateDto dto)
        {
            MessageAfterSeveralConsecutivePossibleAnswersInChannelDto messageAfterSeveralConsecutivePossibleAnswersInChannel = _app.Add(botId, dto);
            return CreatedAtAction(nameof(Get), new { id = messageAfterSeveralConsecutivePossibleAnswersInChannel.Id }, messageAfterSeveralConsecutivePossibleAnswersInChannel);
        }

        [HttpDelete]
        [Route("messageAfterSeveralConsecutivePossibleAnswersInChannels/{id:Guid}")]
        public ActionResult Delete([FromRoute] Guid id)
        {
            _app.Delete(id);
            return NoContent();
        }
    }
}
